<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
<style type="text/css">   
         .tr_td td:nth-child(1) {
            border-left: 1px solid #cccccc;
        } 

		 tr td:nth-child(1) {
            font-size: 14px;
            color: #ffffff;
        }
		 th{
			 color: #ffffff;
		 }
        table tr:nth-of-type(1){
			background-color: #57a0ff;font-weight: 700
		}
		.div_table{
			margin-left: 110px;
		}
		.child input{
			width:120px;
		} 
		 /* .datatable tr:hover,.datatable tr.hilite{
    		background-color:#99FF66; 
    		color:#0000CC;
    	} */
    	.datatable
{
    /* border-collapse:collapse;
    color:#000000; */
    /* font-family:Arial, Helvetica, sans-serif; */
   /*  border:1px solid #000099; */
    /* font-size:14px; */
}
 .datatable th,.datatable td
{
    text-align:left;
    border:0px solid #000000;
    padding-left:4px;
    padding-top:5px;
    padding-bottom:5px;
    padding-left:4px;
    padding-right:4px;
} 
.datatable th
{
    /* color:#000066; */
    /* font-family:宋体,Arial, Helvetica, sans-serif; */
    /* background-color:#CCCCCC; */
    background: #a9bbe0;
}
 .datatable caption
{
    
    background-color:#CCFF66;
    padding:5px 0 5px 0;
}  
 input[type=checkbox]{
	width:13px;
}
 .div_input_hang {
	 width: 100%;
	 height: 40px;
 }
 .input_hang {
	 float: left;
	 width: 500px;
	 height: 40px;
 }

       
</style>
</head>
<body style="background: #f5f5f5">
<div class="main">
	<div class="weizhi">
		人力资源>>薪资发放>>新增
	</div>
	<div class="div_body" style="box-shadow: 0 0 5px #cccccc;height: 1000px">
		<div class="div_form">
			<form  action="<%=path%>/DrivingSys/addRemunProvide" class="form" method="post" onsubmit="return subForm()">
				<div class="jczl">
					<div class="div_input_hang">
						<div class="input_hang">
							<span class="gn_name">驾校&nbsp;:&nbsp;</span>
							<input  type="text" name="departmentFnameL2"  value="${ department.fnameL2}" readonly="readonly" style="color: gray;"/>
						</div>
						<div class="input_hang">
							<span class="gn_name">单据编号&nbsp;:&nbsp;</span>
							<input type="text" class="fnumber" name="fnumber" readonly="readonly" value="${fnumber }">
						</div>
						<div class="input_hang">
							<span class="gn_name">业务日期&nbsp;:&nbsp;</span>
							<input type="text" class="fbizdate" id="fbizdate" readonly="readonly" value="${year }-${month}-${day}" name="fbizdate">
                        <%-- <img onclick="WdatePicker({el:'fbizdate',dateFmt:'yyyy-MM-dd '})"
                             src="<%=path%>/image/date.jpg" align="absmiddle" style="padding-left: 15px"> --%>
						</div>
					</div>
					<div class="div_input_hang">
						<div class="input_hang">
							<span class="gn_name">单据状态&nbsp;:&nbsp;</span>
							<select name="cfbillstate"   style="width: 234px;height: 31px" id="cfstateId" >
                    	    	<option value="3" >新增</option>
                    	    	
                    		</select>
						</div>
						<div class="input_hang">
							<span class="gn_name">年&nbsp;:&nbsp;</span>
							<input type="text" name="cfyear" readonly="readonly" value="${year }">
						</div> 
						<div class="input_hang">
							<span class="gn_name">月&nbsp;:&nbsp;</span>
							<input type="text" name="cfmonth" readonly="readonly" value="${month}">
						</div> 
					</div>
					<div class="div_input_hang">
						<div class="input_hang">
							<span class="gn_name">参考信息&nbsp;:&nbsp;</span>
							<input type="text" name="fdescription">
						</div>
					</div>
					<div class="div_table" style="overflow:auto; height:450px;width:1300px;padding-left: 0px;border:1px solid #ccc">
                <table class="" width="100%" id="table1"
                       style="min-height:50px;overflow:hidden;border-spacing:0;">
                    <tr class="tr">
                    	<th align="center"><input type="hidden"   value=""/></th>
                        <th width="45px" align="center" >职员编码</th>
                        <th width="150px" align="center">职员名称</th>
                        <th width="150px" align="center">部门名称</th>
                        <th width="150px" align="center">基本工资</th>
                        <th width="150px" align="center">晋级工资</th> 
                      	<th width="150px" align="center">绩效工资</th>
                      	<th width="150px" align="center">星级工资</th>
                      	<th width="150px" align="center">加班工资</th>
                      	<th width="150px" align="center">职龄工资</th>
                      	<th width="150px" align="center">培训提成</th>
                      	<th width="150px" align="center">招生提成</th>
                      	<th width="150px" align="center">生日津贴</th>
                      	<th width="150px" align="center">降温/防寒费</th>
                      	<th width="150px" align="center">其他补贴</th>
                      	<th width="150px" align="center">未足月/未打卡扣款</th>
                      	<th width="150px" align="center">社保费</th>
                      	<th width="150px" align="center">个人所得税</th>
                      	<th width="150px" align="center">住宿/水电费</th>
                      	<th width="150px" align="center">违纪罚款</th>
                      	<th width="150px" align="center">物品扣款</th>
                      	<th width="150px" align="center">应发合计</th> 
                    </tr>
                    <c:forEach items="${personList }" var="persons" >
                    <tr class="child">
                    	
                    	<td><input  type="checkbox" name=""  value="${persons.fid }"  onclick="changeName($(this));" /></td>
						<td><input  type="text" class="fseq" name=""
										readonly="readonly" value="${persons.fnumber }" ></td>
						<td><input  type="text" class="fseq" name=""
										readonly="readonly" value="${persons.fnameL2 }" ></td>
						<td><input type="text" class="fseq" name=""
										readonly="readonly" value="${persons.cfpersondepName }" ></td>
						<td><input type="text" class="price"  name="basePay"
										value="" ></td>
						<td><input type="text" class="price"  name="promotePay"
										value="" ></td>
						<td><input type="text" class="price" name="performancePay"
										value="" ></td>
						<td><input type="text" class="price" name="starPay"
										value="" ></td>
						<td><input type="text" class="price" name="overtimePay"
										value="" ></td>
						<td><input type="text" class="price" name="positionAgePay"
										value="" ></td>
						<td><input type="text" class="price" name="trainPay"
										value="" ></td>
						<td><input type="text" class="price" name="recruitPay"
										value="" ></td>
						<td><input type="text" class="price" name="birthdayPay"
										value="" ></td>
						<td><input type="text" class="price" name="coolingPay"
										value="" ></td>
						<td><input type="text" class="price" name="elsePay"
										value=" "></td>
						<td><input type="text" class="price" name="notFullMonthPay"
										value="" ></td>
						<td><input type="text" class="price" name="securityPay"
										value="" ></td>
						<td><input type="text" class="price" name="personalPay"
										value="" ></td>
						<td><input type="text" class="price" name="livePay"
										value="" ></td>
						<td><input type="text" class="price" name="breakPay"
										value="" ></td>
						<td><input type="text" class="price" name="goodsPay"
										value="" ></td>
						<td><input type="text" class="cfamount"  readonly="readonly" name=""
										value="0" ></td> 
					</tr>
					</c:forEach> 
                </table>
            </div>
            <div class="div_input_hang">
						
			</div>	
			<div class="div_input_hang">
						<div class="input_hang">
							<span class="gn_name">审核人&nbsp;:&nbsp;</span>
							<input  type="text" name="checkName"  value="" readonly="readonly" style="color: gray;"/>
						</div>
						<div class="input_hang">
							<span class="gn_name">创建者&nbsp;:&nbsp;</span>
							<input type="text" name="createName" readonly="readonly" value="${createName }">
						</div>
						<div class="input_hang">
							<span class="gn_name">创建时间&nbsp;:&nbsp;</span>
							<input type="text" id="fcreatetime" value="${createTime }" name="fcreatetime"
                               onclick="WdatePicker({el:'fcreatetime',dateFmt:'yyyy-MM-dd HH:mm:ss'})">
                        <img onclick="WdatePicker({el:'fcreatetime',dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                             src="<%=path%>/image/date.jpg" align="absmiddle" style="padding-left: 15px">
						</div>
					</div>
				<div class="div_tj">
					<div>
						<input  type="submit" class="input_submit bc" value="" style="margin-right: 30px;"/>
					</div>
					<div>
						<input type="button" class="input_back fh"  value="" onclick="back()"/>
					</div>
				</div>
				</div>
			</form>
		</div>
	</div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<%@ include file="/WEB-INF/JSP/ajax.jsp" %>
<script type="text/javascript">
    $(document).ready(function(){
        var type = "${type}";
        if(type == '0' || type == '' || type == null) {

        }else{
            //alert("添加成功");
			editAlert();
        }
    })
	
	$("#llhy").blur(function(){
		//只能输入数字和小数点
		var re = /^\d+(?=\.{0,1}\d+$|$)/ 
		//理论油耗的值
		var llhy = $(this).val();
		//判断只能输入数字和小数点
		if(llhy == ""){
			$(".haoyou").css("display","none");
		}else if(!re.test(llhy)){
			$(".haoyou").css("display","inline");
			$(this).val("")
		}else{
			$(".haoyou").css("display","none");
		}
	})
	
	$("#gmjg").blur(function(){
		//只能输入数字和小数点
		var re = /^\d+(?=\.{0,1}\d+$|$)/ 
		//理论油耗的值
		var gmjg = $(this).val();
		//判断只能输入数字和小数点
		if(gmjg == ""){
			$(".jiage").css("display","none");
		}else if(!re.test(gmjg)){
			$(".jiage").css("display","inline");
			$(this).val("")
		}else{
			$(".jiage").css("display","none");
		}
	})

    //键盘事件
    $(".price").live('keyup', function(event) {
        //最后一位是小数点的话，移除
        var $amountInput = $(this);
        //响应鼠标事件，允许左右方向键移动
        event = window.event || event;
        if(event.keyCode == 37 | event.keyCode == 39) {
            return;
        }
        //先把非数字的都替换掉，除了数字和.
        $amountInput.val($amountInput.val().replace(/[^\-?\d.]/g, "").
        //只允许一个小数点
        replace(/^\./g, "").replace(/\.{2,}/g, ".").
        //只能输入小数点后两位
        replace(".", "$#$").replace(/\./g, "").replace("$#$", ".").replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'));
        machMoney();
    });
    function machMoney() {
        //计算工资
        $("#table1 tr").keyup(function(){
            var td=$(this).find("td")
            var flag=td.eq(0).children("input").prop("checked")
            if(!flag){
                alert("操作前，请先勾选此行!")
                for(var i=4;i<td.length;i++){
                    td.eq(i).children("input").val("")//清空输入的值
                }

            }else{
                var sum=0
                for(var i=4;i<td.length-1;i++){
                    var date=td.eq(i).children("input").val()
                    date=Number(date)
                    if(i<=14){
                        sum+=date
                    }
                    if(i>=15){//这里是扣款项目
                        sum-=date
                    }

                }
                td.eq(2).children("input").attr("name","personName")
                td.eq(3).children("input").attr("name","cfpersondepName")
                td.eq(td.length-1).children("input").attr("name","cfamount")
                td.eq(td.length-1).children("input").val(sum)//总钱
            }
        })
    }

	//点击改变复选框的name值
	function changeName(obj){
		if (obj.is(":checked")) {   	
	       obj.attr("name","check");
	       obj.parent().parent().find("td").eq(1).children("input").attr("name","funmber");
           obj.parent().parent().find("td").eq(2).children("input").attr("name","personName");
           obj.parent().parent().find("td").eq(3).children("input").attr("name","cfpersondepName");
            obj.parent().parent().find("td").eq(21).children("input").attr("name","cfamount");
	    }else{//不选中name值为空
	    	obj.attr("name","")
            obj.parent().parent().find("td").eq(1).children("input").attr("name","");
            obj.parent().parent().find("td").eq(2).children("input").attr("name","");
            obj.parent().parent().find("td").eq(3).children("input").attr("name","");
            obj.parent().parent().find("td").eq(21).children("input").attr("name","");}
	}
	/* function check2(){
		if($("#fcreatetime").val()==null || $("#fcreatetime").val()==''){
			alert("创建时间不能为空!")
			$("#fcreatetime").focus()
			return false	
		}
		return true
	} */
	//返回
	function back(){
		location = '<%=path%>/DrivingSys/queryRemunProvide/look.action';
	}
    function subForm(){
	    var count=0;
       $("input:checkbox[name=check]:checked").each(function(){
			count++;
	   })
		if(count == 0){
           alert("请至少添加一名职员工资!")
			return false;
		}
        $("input[type='submit']").attr("disabled", "disabled");
    }
</script>
</html>